//结构体数组
#include <stdlib.h>
#include "stdio.h"
#include "string.h"

struct Student {
    char name[10];
    int age;
    float score;
};
typedef struct Student STU;//给结构体起别名
typedef struct Student *PSTU;//给结构体指针起别名
int main() {
    //栈区，静态范畴
    struct Student stu[5] = {
            {"张三", 18, 100},
            {"李四", 19, 99},
            {"王五", 20, 98},
            {},
            {}

    };
    STU stu3 = {"赵六", 21, 96};
    struct Student stu4 = {"王7", 22, 11};
    stu[3] = stu3;
    *(stu + 4) = stu4;
    printf("姓名%s 年龄%d 分数%f\n", stu[4].name, stu[4].age, stu[4].score);

    // 堆区  动态范畴============================================================

    PSTU pstu = malloc(sizeof(STU) * 5);
    struct Student *p = malloc(sizeof(struct Student) * 5);


    //移动指针的方式
    p++;
    strcpy(p->name, "赵六2");
    p->age = 211;
    p->score = 986;

    printf("======姓名%s 年龄%d 分数%f\n", p->name, p->age, p->score);



    free(p);
    p = NULL;

    return 0;
}